using System;
using System.Diagnostics;
using System.Text;
using Debug = UnityEngine.Debug;

namespace IQIGame.Onigao.Framework
{
    public static class LogGame
    {
        public static bool allowLog = true;

        /// <summary>
        ///  log接口
        ///  通过Conditional("UNITY_EDITOR")，可以在真机包上消除所有Log的调用代码。
        ///  所以推荐直接LogGame.Log($"{xx}xxx")的方式用一行代码的方式输出。
        ///  切记不能写在两行，例如 string msg = $"{xx}xxx"; LogGame.Log(msg)
        /// </summary>
        /// <param name="message"></param>

        [Conditional("UNITY_EDITOR")]
        public static void Log(object message)
        {
            if (allowLog)
            {
                UnityEngine.Debug.Log(message);
            }
        }

        //public static void LogFormat(string format, params object[] args)
        //{
        //    UnityEngine.Debug.LogFormat(format, args);
        //}

        public static void LogError(object message)
        {
            if (allowLog)
            {
                Debug.LogError(message);
            }
        }

        public static void LogException(Exception e)
        {
            Debug.LogException(e);
        }

        //public static void LogErrorFormat(string format, params object[] args)
        //{
        //    Debug.LogErrorFormat(format, args);
        //}

        public static void LogWarning(object message)
        {
            if (allowLog)
            {
                Debug.LogWarning(message);
            }
        }

        //public static void LogWarningFormat(string message, params object[] args)
        //{
        //    Debug.LogWarningFormat(message, args);
        //}

    }



#if UNITY_EDITOR
    public class EditorLog
    {
        public static StringBuilder battleCommandLog;

        [Conditional("UNITY_EDITOR")]
        public static void AppendBattleCommandLog(object obj)
        {
            if (!LogGame.allowLog || battleCommandLog == null)
            {
                return;
            }
            battleCommandLog.AppendLine(obj.ToString());
        }

        public static StringBuilder battleDamageLog;
        [Conditional("UNITY_EDITOR")]
        public static void AppendDamageLog(object obj)
        {
            if (!LogGame.allowLog || battleDamageLog == null)
            {
                return;
            }
            battleDamageLog.AppendLine(obj.ToString());
        }
    }
#endif
}
